#!/bin/sh

if [ -n "$1" ]; then
    echo "Building for android $1 architecture"
else
    echo "Please specify the android architecture to build. e.g. $0 x86"
    exit 1
fi

cd "$(dirname "$0")"
cd ../..
cd tensorflow

#bazel build -c opt //tensorflow/tfextern:libtfextern.so \
#--crosstool_top=external:android/crosstool \
#--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
#--cpu=$1 
#bazel clean

bazel build -c opt \
      --cpu=$1\
      --cxxopt='--std=c++11' \
      --crosstool_top=external:android/crosstool \
      --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
      //tensorflow/tfliteextern:libtfliteextern.so
      
cd ..

mkdir -p lib/android/$1
cp -rf tensorflow/bazel-bin/tensorflow/tfliteextern/*.so lib/android/$1
